<template>
    <div>
        <!-- 顶部滑动条 -->
        <div id="slider" class="mui-slider">
			<div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
				<div class="mui-scroll">
					<a :class="['mui-control-item', item.id== 0 ? 'mui-active':'']" v-for="item in category" :key="item.id" @tap="getAllListByCategoryId(item.id)">
						{{item.title}}  
						<!-- tap 代替 click  只有 MUI 组件能使用 -->
					</a>
				</div>
			</div>
		</div>
 
		<!-- 图片列表区域 -->
		<ul class="photo-list">
  			<router-link v-for="item in list" :key="item.id" :to="'/home/photoinfo/'+item.id" tag="li">
    			<img v-lazy="item.img_url">
				<div class="info">
					<h1 class="info-title">{{item.title}}</h1>
					<div class="info-body">{{item.zhaiyao}}</div>
				</div>
  			</router-link>
		</ul>
    </div>
</template>

<script>
// 导入 MUI 的JS
import mui from '../../lib/mui/js/mui.min.js'
import Toast from 'mint-ui'
export default {
    data(){
        return {
			category: [  // 所有分类的列表数组
				{"title": "推荐", id: 1},
				{"title": "军事", id: 2},
				{"title": "热点", id: 3},
				{"title": "明星", id: 4},
				{"title": "情感", id: 5},
				{"title": "养生", id: 6},
				{"title": "科技", id: 7},
				{"title": "教育", id: 8},
			],
			list: [ // 图片列表的数组
				{
					id: 1,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "生活中总需要只宠物来与之陪伴，有人喜欢猫，有人喜欢狗，有人喜欢兔子，更有甚者喜欢蜥蜴，蛇，蜘蛛等冷门宠物。本图集收集了蠢哈、萌猫、呆兔等动物界各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
					{
					id: 2,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
					{
					id: 3,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
					{
					id: 4,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
				{
					id: 5,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
					{
					id: 6,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
					{
					id: 7,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
				{
					id: 8,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
					{
					id: 9,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
					{
					id: 10,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
				{
					id: 11,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
					{
					id: 12,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
					{
					id: 13,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
				{
					id: 14,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
					{
					id: 15,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
					{
					id: 16,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
				{
					id: 17,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
					{
					id: 18,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
					{
					id: 19,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
				{
					id: 20,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
					{
					id: 21,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
					{
					id: 22,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
				{
					id: 23,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
					{
					id: 24,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
					{
					id: 25,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
				{
					id: 26,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
					{
					id: 27,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
					{
					id: 28,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
				{
					id: 29,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
					{
					id: 30,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				},
					{
					id: 31,
					title: "有气质且带可爱的宠物组图",
					img_url: "http://m.360buyimg.com/mobilecms/s750x750_jfs/t25423/210/595641103/258244/e91db19a/5b7538baN61ea8eda.jpg!q80.dpg.webp",
					zhaiyao: "收集了各种实力萌宠，各种卖萌耍贱，各种活宝表现，尽在此图集中"
				}
			] 
		}
	},
	created(){
		this.getAllCategory();
		// 默认进入主页，就主动请求 所有图片列表的数据
		this.getAllListByCategoryId(0)
	},
    mounted(){ // 当 组件中的 DOM 结构 被渲染好并放到页面中后，会执行这个钩子函数
        // 初始化 滑动控件
        mui('.mui-scroll-wrapper').scroll({
	        deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
        });
    },
    methods: {
		// getAllCategory(){ // 获取所有的图片列表
		// 	this.$http.get('api/getimgcategory').then(result => {
		// 		if(result.body.status === 0){
		// 			//手动拼接 一个 完整的分类列表
		// 			result.body.message.unshift({title:"全部", id: 0})
		// 			this.category = result.body.message;
		// 		}else {
		//			Toast('╮(╯▽╰)╭获取类目列表失败')
		//		}
		//
		// 	})
		// }
 
		//手动拼接 一个 完整的分类列表
		getAllCategory(){
			this.category.unshift({title:"全部", id: 0})
		},

		// getAllListByCategoryId(cateId){
		// 	// 根据 分类id, 获取图片列表
		// 	this.$http.get('api/getimages' + cateId).then(result => {
		// 		if(result.body.status === 0){
		// 			this.list = result.body.message
		// 		}else {
		// 			Toast('╮(╯▽╰)╭切换图片列表失败！！！')
		// 		}
		// 	})
		// }	 

		getAllListByCategoryId(cateId){
			this.list;
		}
    }
}
</script>

<style lang="scss" scoped>
* {
    touch-action: pan-y; 
}


.photo-list {
	list-style-type: none;
	margin: 0;
	padding: 10px;
	padding-bottom: 0;

	li {
		background-color: #ccc;
		text-align: center;
		margin-bottom: 10px;
		box-shadow: 0 0 9px #999;
		position: relative;

		img{
			width: 100%;
			vertical-align: middle;
		}

		img[lazy=loading] {
		width: 40px;
		height: 300px;
		margin: auto;
		}

		.info {
			width: 100%;
			color: white;
			text-align: left;
			position: absolute;
			bottom: 0;
			background-color: rgba(0,0,0,0.4);
			max-height: 85px;

			.info-title{
				font-size: 14px;
			}
			.info-body{
				font-size: 13px;
				// white-space: nowrap;  /* 强制一行内显示所有文本，直到文本结束或遇到不可抗力因素<br/>*/
				// overflow: hidden;   /*隐藏溢出的文本*/
				// text-overflow: ellipsis;   /*溢出的文字用省略号表示*/
				// margin: -1px;
			}
		}
	
	}
}



</style>

